package cn.tedu.ivos.dict.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.dict.pojo.dto.DictParam;
import cn.tedu.ivos.dict.pojo.dto.DictQuery;
import cn.tedu.ivos.dict.pojo.vo.DictVO;
import cn.tedu.ivos.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("/v1/dict")
@RestController
public class DictController {
    @Autowired
    DictService dictService;



    @GetMapping("select")
    public JsonResult dictselect(DictQuery dictQuery){
        log.debug("查询所有字典"+dictQuery);
          List<DictVO> list= dictService.dictselect(dictQuery);
        return JsonResult.ok(list);

    }
    @PostMapping("save")
    public JsonResult dictsave(DictParam dictParam){
        log.debug("保存字典"+dictParam);
        dictService.dictsave(dictParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    public JsonResult dictdelete(@PathVariable Long id){
        log.debug("删除字典"+id);
        dictService.dictdelete(id);
        return JsonResult.ok();

    }

}
